package com.yspa.drugRemind.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hsnn.medstgmini.dao.HibernateSqlUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.yspa.drugRemind.dao.DrugRemindDao;

@Repository
public class DrugRemindDaoImpl implements DrugRemindDao {

	@Autowired
	private HibernateSqlUtil dao;
	public Pagination getDrugRemindList(Pagination page){
		StringBuffer sql = new StringBuffer();
		sql.append("select * from drug_remind")
		.append(" where 1=1 ");
		Map<String, Object> params = new HashMap<String, Object>();
		if (StringUtils.isNotBlank(page.getConditions().get("title"))){
			sql.append(" and title like :title");
			params.put("title", "%" + page.getConditions().get("title").trim() + "%");
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	public List getDataInfo(String id){
		String sql = "select * from drug_remind where id=:id";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		return dao.getSqlMapList(sql, params);
	}
}
